<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>修改个人密码</title>
<%@include file="../include/includecss.jsp"%>
</head>
<body>
<%@include file="../include/includemenu.jsp"%>

	<div class="container theme-showcase container-fixed-top" role="main">
		<div class="col-sm-8">
			<div class="panel panel-default">
				<div class="panel-heading">
					<h3 class="panel-title">修改个人密码</h3>
				</div>
			</div>
			<div class="panel-body">
			<p>${changePWDState}</p>
				<form class="form-horizontal" onsubmit="return checkInfoa()" method="POST" action="${pageContext.request.contextPath }/ChangPwdServlet">
					
					<div clsss="form-group">
						<label class="col-sm-2 control-label">旧密码:</label>
						<div class="col-sm-10">
							<input type="password" name="password" class="form-control"
								id="form_password" placeholder="旧密码" value="${regUser.userSecretBean.pwd}"/>
						</div>
					</div>
					<div class="form-group">
					<label class="col-sm-4 control-label">&nbsp;</label>
					</div>
					<div clsss="form-group">
						<label class="col-sm-2 control-label">新密码:</label>
						<div class="col-sm-10">
							<input type="password" name="cPassword" class="form-control"
								id="form_cPassword" placeholder="确认密码" />
						</div>
					</div>
					<div class="form-group">
					<label class="col-sm-4 control-label">${ChangePWDMessage}&nbsp;</label>
					<label class="col-sm-8 control-label">&nbsp;</label>
					</div>
					<div clsss="form-group">
						<label class="col-sm-2 control-label">验证码:</label>
						<div class="col-sm-10">
								<input type="text" name="Vcode" class="form-control"
									id="form_Vcode" placeholder="验证码" />
						<img src="${pageContext.request.contextPath }/VCode" class="img-responsive" alt="Responsive image" width=60px height=30px/>
					
						</div>
					</div>
					<div class="form-group">
					<label class="col-sm-4 control-label">${ChangePWDVcodeMessage}&nbsp;</label>
					<label class="col-sm-8 control-label">&nbsp;</label>
					</div>
					<div class="form-group">
						<div class="col-sm-offset-2 col-sm-10">
							<button type="submit" class="btn btn-default">修改</button>
						</div>
					</div>
				</form>
			</div>
		</div>
		<div class="col-sm-4"></div>
	</div>
	<%@ include file="../include/bottom.jsp"%>
	<script type="text/javascript">
		function checkInfoa() {
			//alert($('#form_userEmail').val());
			if (checkUserName() && checkEmail() && checkPassword()
					&& checkUserNice())
				return true;
			else
				return false;
		}
		//检查用户昵称
		function checkUserNice() {
			var s;
			s = $("#form_userNice").val();
			if (s.length<5 || s.length>16) {
				alert('用户昵称需要为6-16个字符！');
				$('#form_userNice').parent().addClass("has-error");
				return false;
			}
			$('#form_userNice').parent().removeClass("has-error");
			return true;
		}
		function checkUserName() {
			var s;
			s = $("#form_UserName").val();
			if (s.length<5 || s.length>16) {
				alert('用户名需要为6-16个字符！');
				$('#form_UserName').parent().addClass("has-error");
				return false;
			}

			if (!isChinaOrNumbOrLett(s)) {
				alert("用户名需要包含英文以及数字");
				$('#form_UserName').parent().addClass("has-error");
				return false;
			}
			$('#form_UserName').parent().removeClass("has-error");
			return true;
		}

		function isChinaOrNumbOrLett(s) {//判断是否是汉字、字母、数字组成 

			var regu = "^[0-9a-zA-Z\u4e00-\u9fa5]+$";
			var re = new RegExp(regu);
			if (re.test(s)) {
				return true;
			} else {
				return false;
			}
		}

		function checkPassword() {
			var pwd = $("#form_password").val();
			var cpwd = $("#form_cPassword").val();
			if (pwd.length<5||pwd.length>16) {
				$('#form_password').parent().addClass("has-error");
				alert('密码需要再5到16位之间！');
				return false;
			}
			if (pwd != cpwd) {
				$('#form_cPassword').parent().addClass("has-error");
				alert("两次密码输入不一致，请重新输入");
				return false;
			}
			$('#form_password').parent().removeClass("has-error");
			$('#form_cPassword').parent().removeClass("has-error");
			return true;
		}
		function checkEmail() {
			var strEmail = $('#form_userEmail').val();
			var emailReg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
			if (emailReg.test(strEmail)) {
				$('#form_userEmail').parent().removeClass("has-error");
				return true;
			} else {
				$('#form_userEmail').parent().addClass("has-error");
				alert("您输入的Email地址格式不正确！");
				return false;
			}
		}
	</script>

</body>
</html>